package com.xintoucloud.xxx.springquartz;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.xintoucloud.gsv.entity.SuperVision;
import com.xintoucloud.gsv.service.SuperVisionService;

@Component
@EnableScheduling
public class SuperVisionIsUnReplyQuartz {
	@Autowired
	private SuperVisionService superVisionService;
	@Scheduled(cron = "0/1 * * * * ?")
    public void isUnReply() throws ParseException{
		Date date=new Date();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		//先从数据库中查询
		List<SuperVision> list=superVisionService.list();
		for (SuperVision superVision : list) {
			Date endTime=sdf.parse(superVision.getEndTime());
			if((long)(date.getTime()-endTime.getTime())>=0&&superVision.getSuperVisionState().getStid()==3) {
				superVisionService.updateStid(9, superVision.getSvid());
				System.out.println("督办事件规定回复时间："+superVision.getEndTime()+",这个标题为:"+superVision.getSvTitle()+"，id为:"+superVision.getSvid()+"逾期未签收");
			}
		}        
    }
	
}
